package com.heima.shopweb.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.core.util.JsonResult;
import com.zijie.order.model.Order;
import com.zijie.order.model.OrderItem;
import com.zijie.order.model.search.OrderSearchBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(value = "shop-gateway", contextId = "order-feign")
public interface OrderFeignService {
    //新建订单
    @PostMapping("/order-api/api/v1/order/save")
    public ResponseEntity<JsonResult<?>> save(@RequestBody Order order);
    //同时新增订单项
    @PostMapping("/order-api/api/v1/orderItem/save")
    public ResponseEntity<JsonResult<?>> saveOrderItem(@RequestBody List<OrderItem> orderItems);

    //修改订单
    @PutMapping("/order-api/api/v1/order/update")
    public ResponseEntity<JsonResult<?>> update(Order order);


    //获取当前用户的订单信息
    @GetMapping("/order-api/api/v1/order/all")
    public ResponseEntity<JsonResult<List<Order>>> findAll2(@SpringQueryMap OrderSearchBean osb);
    //根据订单id查订单项
    @GetMapping("/order-api/api/v1/orderItem/findByOrderId/{id}")
    public ResponseEntity<JsonResult<List<Map<String,Object>>>> findByOrderId(@PathVariable("id") Integer id);

}
